package com.zhiyou100.weather.config;


import com.zhiyou100.weather.job.WeatherJob;
import com.zhiyou100.weather.job.WoJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ScheduleConfig {
    @Bean
    public JobDetail m2() {
        //将创建好的任务加载进来，并且命名，分配群组
        return JobBuilder.newJob(WeatherJob.class).withIdentity("job1")
                .storeDurably().build();

    }

    @Bean
    public Trigger m1() {
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(3).repeatForever();
        // 创建trigger对象

        return TriggerBuilder.newTrigger()
                .forJob(m2()).withIdentity("job").withSchedule(scheduleBuilder).build();

    }
}
